
#if !defined( __TAG_FOLDER_H__)
#define __TAG_FOLDER_H__

#if defined( __cplusplus)
extern "C"{
#endif

#include <stdlib.h>
#include "tf_list.h"

enum tf_status{
    TF_OK=0x1,
    TF_SQLERR=0x2,
    TF_DRVERR=0x4
};

#if defined(__GNUC__)
#define TF_INLINE inline
#else
#define TF_INLINE
#endif

#if defined( DEFAULT_LIST_SIZE)
#undef DEFAULT_LIST_SIZE
#endif
#define DEFAULT_LIST_SIZE   16u

int tf_init( int argc, char** argv);
int tf_destroy( void );

int define_tag( const char* tag);
int if_tag_defined( const char* tag);
int undefine_tag( const char* tag);

int link_tags( const char* tag1, const char* tag2, const char *relation);
int if_tags_related( const char* tag1, const char* tag2, const char* relation);
int unlink_tags( const char* tag1, const char* tag2, const char* relation);

int define_relation( const char* relation);
int if_relation_defined( const char* relation);
int undefine_relation( const char* relation);

int tag_file( const char* file, const char* tag);
int if_file_tagged( const char* file);
int untag_file( const char* file, const char * tag);

int list_tags_of_file( const char* file, string_list** tags);
int list_files_of_tag( const char* tag, string_list** files);
int list_all_tags( string_list** tags);
int list_all_files( string_list** files);

/**
 * Tag operations;
 */
typedef struct tag_db{
    void *place_holder1;
    void *place_holder2;
    void *place_holder3;
    void *place_holder4;

    int (*define_tag) ( const char*);
    int (*if_tag_defined) ( const char*);
    int (*undefine_tag) ( const char*);

    int (*link_tags) ( const char* t1, const char* t2, const char* rel);
    int (*if_tags_related) ( const char* t1, const char* t2, const char* rel);
    int (*unlink_tags) ( const char* t1, const char* t2, const char* rel);

    int (*define_relation) ( const char*);
    int (*if_relation_defined) ( const char*);
    int (*undefine_relation) ( const char*);

    int (*tag_file) ( const char* file, const char* tag);
    int (*if_file_tagged) ( const char*);
    int (*untag_file) (const char* file, const char* tag);

    int (*list_tags_of_file) (const char* file, string_list** tags);
    int (*list_files_of_tag) (const char* tag, string_list** files);
    int (*list_all_tags) ( string_list**);
    int (*list_all_files) ( string_list**);
}tag_db;

enum file_type{
    FTYPE_LOCALFS=0x1,
    FTYPE_EMAIL=0x2,
    FTYPE_HTTP=0x4,
    FTYPE_CONTACT=0x8,
    FTYPE_UNKNOW=0xFFFFFFFF
};

#if defined( __cplusplus)
}   // extern "C"{
#endif

#endif // #if defined( __TAG_FOLDER_H__)
